package map;

import java.io.Serializable;

/* TODO
 * Name
 * HP
 * Notes
 * Visibility With Respect to Players
 * Owner?
 * Change Size
 */
/**
 * Represents a item in a MapData object
 * with a rotation and a type.
 * Its type corresponds to the ID of an entry in a MapLibrary.
 * Its rotation is an integer in quarter-turns clockwise
 * for it default position.
 * 
 * @author Alex Babis
 */
public class MapDataItemInstance implements Serializable
{
    private static final long serialVersionUID = 1L;
    private int type;       // Corresponds to an ID in the library
    private int rotation;   // In quarter-turns clockwise
    private int width;      // The width in squares of this item
    private int height;     // The height in squares of this item
	
	/**
	 * Creates a new item
	 * @param type		The ID for the corresponding MapLibrary entry
	 * @param rotation	Direction of this item in quarter-turns clockwise
	 * from the default position. 0 is the default position
	 */
	public MapDataItemInstance(int type, int rotation, int width, int height)
	{
		this.type = type;
		this.rotation = rotation;
		this.width = width;
		this.height = height;
	}
	
	/** Gets a number corresponding to the ID in a MapLibrary
	 *  for this instance
	 * @return The item type for this entry */
	public int getType(){return type;}
    
    /** Gets the unique ID for this item entry
     * @return The unique ID for this item entry */
    public int getRotation(){return rotation;}
    
    /** Gets the width in squares for this item entry
     * @return The width in squares for this item entry */
    public int getWidth(){return width;}
    
    /** Gets the height in squares for this item entry
     * @return The height in squares for this item entry */
    public int getHeight(){return height;}

	/** Rotates this item 90 degrees clockwise */
	public void rotateCW(){rotation = (rotation + 1) % 4;}

	/** Rotates this item 90 degrees counter-clockwise */
	public void rotateCCW(){rotation = (rotation + 3) % 4;}

	/** Sets the rotation of this item in quarter-turns
	 * clockwise. 0 is the default position */
	public void setRotation(int rotation){this.rotation = rotation;}
}